package com.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.api.common.jwt.TokenIgnore;
import com.api.common.reqres.Request;
import com.api.common.reqres.Response;
import com.api.model.request.ApplicationLeaveRequest;
import com.api.model.request.CancelLeaveRequest;
import com.api.model.request.NullRequest;
import com.api.model.response.LeaveResponse;
import com.api.model.response.NullResponse;
import com.api.service.LeaveService;

import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 请假
 * </p>
 *
 * @author cfp
 * @since 2019-10-14
 */
@TokenIgnore
@RestController
public class LeaveController {
	@Autowired
	private LeaveService leaveService;

	@ApiOperation(notes = "请假记录", value = "请假记录")
	@PostMapping(value = "/leave.do")
	public Response<LeaveResponse> leave(@RequestBody Request<NullRequest> request) throws Exception {
		return leaveService.leave(request);
	}

	@ApiOperation(notes = "申请请假", value = "申请请假")
	@PostMapping(value = "/applicationLeave.do")
	public Response<NullResponse> applicationLeave(@RequestBody Request<ApplicationLeaveRequest> request)
			throws Exception {
		return leaveService.applicationLeave(request);
	}

	@ApiOperation(notes = "撤销请假", value = "撤销请假")
	@PostMapping(value = "/cancelLeave.do")
	public Response<NullResponse> cancelLeave(@RequestBody Request<CancelLeaveRequest> request) throws Exception {
		return leaveService.cancelLeave(request);
	}
}
